﻿using System;
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Client : MonoBehaviour
{        
    public  Text                m_Hint;
    public MultiDownloder       multiDownloader;
    public ZipDownloader        zipDownloader;
   
    void Start()
    {
        //multiDownloader.DownloadJson("http://192.168.1.128:9888/images/zipInfo.json");
        //multiDownloader.EventMultiDownloadSuccess += OnMultiDownloadSuccess;
        //multiDownloader.EventMultiDownloadFail += OnMultiDownloadFail;

        zipDownloader.Download("http://192.168.1.128:9888/images/ios__v21_1__to__v21_19.zip");
        zipDownloader.EventZipDownloadSuccess += OnZipDownloadSuccess;
        zipDownloader.EventZipDownloadFail += OnZipDownloadFail;
        zipDownloader.EventZipDownloadProgress += OnZipDownloadProgress;

        m_Hint.text = "start download";
    }

    private void OnZipDownloadSuccess()
    {
        m_Hint.text = "OnZipDownloadSuccess";
        Debug.Log("---- OnZipDownloadSuccess");
    }

    private void OnZipDownloadFail(ZipDownloaderError error)
    {
        m_Hint.text = "OnZipDownloadFail";
        Debug.Log("---- OnZipDownloadFail");
    }

    private void OnZipDownloadProgress(float progress)
    {
        m_Hint.text = "" + progress;
    }

    private void OnMultiDownloadSuccess()
    {
        m_Hint.text = "OnMultiDownloadSuccess";
        Debug.Log("[client] OnMultiDownloadSuccess");
    }

    private void OnMultiDownloadFail()
    {
        m_Hint.text = "OnMultiDownloadFail";
        Debug.Log("[client] OnMultiDownloadFail");
    }        
   
    void Update()
    {

    }

}
